package com.ruoyi.Label.service.impl;

import java.util.List;

import com.ruoyi.Goover.domain.StudyEnglish;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.Label.mapper.StudyLableMapper;
import com.ruoyi.Label.domain.StudyLable;
import com.ruoyi.Label.service.IStudyLableService;

/**
 * 存储标签的库Service业务层处理
 * 
 * @author luobom
 * @date 2021-12-03
 */
@Service
public class StudyLableServiceImpl implements IStudyLableService 
{
    @Autowired
    private StudyLableMapper studyLableMapper;

    /**
     * 查询存储标签的库
     * 
     * @param uid 存储标签的库主键
     * @return 存储标签的库
     */
    @Override
    public StudyLable selectStudyLableByUid(String uid)
    {
        StudyLable stu=studyLableMapper.selectStudyLableByUid(uid);
        if(stu!=null) {
            if(!stu.getCreateBy().equals(String.valueOf(SecurityUtils.getUserId()))){
                stu=null;
            }
        }
        return stu;
    }

    /**
     * 查询存储标签的库列表
     * 
     * @param studyLable 存储标签的库
     * @return 存储标签的库
     */
    @Override
    public List<StudyLable> selectStudyLableList(StudyLable studyLable)
    {
        studyLable.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        return studyLableMapper.selectStudyLableList(studyLable);
    }

    /**
     * 新增存储标签的库
     * 
     * @param studyLable 存储标签的库
     * @return 结果
     */
    @Override
    public int insertStudyLable(StudyLable studyLable)
    {
        studyLable.setCreateTime(DateUtils.getNowDate());
        studyLable.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        return studyLableMapper.insertStudyLable(studyLable);
    }

    /**
     * 修改存储标签的库
     * 
     * @param studyLable 存储标签的库
     * @return 结果
     */
    @Override
    public int updateStudyLable(StudyLable studyLable)
    {
        studyLable.setUpdateTime(DateUtils.getNowDate());
        return studyLableMapper.updateStudyLable(studyLable);
    }

    /**
     * 批量删除存储标签的库
     * 
     * @param uids 需要删除的存储标签的库主键
     * @return 结果
     */
    @Override
    public int deleteStudyLableByUids(String[] uids)
    {
        return studyLableMapper.deleteStudyLableByUids(uids);
    }

    /**
     * 删除存储标签的库信息
     * 
     * @param uid 存储标签的库主键
     * @return 结果
     */
    @Override
    public int deleteStudyLableByUid(String uid)
    {
        return studyLableMapper.deleteStudyLableByUid(uid);
    }
}
